package com.lsh.oms.core.exception;

import com.lsh.base.common.exception.BusinessException;

/**
 * Project Name: lsh-groupon
 * Author: panxudong
 * 北京链商电子商务有限公司
 * Desc: 类功能描述
 * Package Name: com.lsh.groupon.core.exception
 * Time: 2017-06-29 下午3:15
 */
public enum ExBase {

    ERROR("999999", "系统错误!"),

    ERROR_PARAMS("E000001", "请求参数错误！"),

    ERROR_SEND_MESSAGE("E000002", "发送短信错误！"),

    ERROR_GET_WEI_XIN_CONFIG("E000003", "获取微信配置错误！"),

    ERROR_GET_CONFIG("E000004", "获取配置错误！");

    private final String code;

    private final String message;

    ExBase(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public BusinessException exception() {
        return new BusinessException(this.getCode(), this.getMessage());
    }

    public BusinessException exception(String message) {
        return new BusinessException(this.getCode(), new StringBuilder(this.message).append("\n").append(message).toString());
    }

    public BusinessException exception(Throwable e) {
        return new BusinessException(this.getCode(), new StringBuilder(this.message).append("\n").append(e.getMessage()).toString(), e);
    }
}
